package com.smh.a08HuToolDemo1;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class HuToolDemo1 {
    public static void main(String[] args) {

        File file = FileUtil.file("day27-code", "c");
        System.out.println(file);//D:\develop\Code\JavaCode\javaclass\out\production\day27-code\c\a\z\t.txt

        //即便父级路径不存在也不会报错,而是帮我们创建
        File touch = FileUtil.touch("day27-code", "file\\demo6\\a\\a.txt");
        System.out.println(touch);

        ArrayList<String> list = new ArrayList<>();
        list.add("asd");
        list.add("qwe");
        list.add("zxc");
        //覆盖
        File file2 = FileUtil.writeLines(list, "D:\\develop\\Code\\JavaCode\\javaclass\\day27-code\\file\\demo6\\a\\a.txt", "UTF-8");
        System.out.println(file2);
        //追加
        File file1 = FileUtil.appendLines(list, "D:\\develop\\Code\\JavaCode\\javaclass\\day27-code\\file\\demo6\\a\\a.txt", "UTF-8");
        System.out.println(file1);
        //读取
        //(一行为一个元素)
        List<String> list1 = FileUtil.readLines("D:\\develop\\Code\\JavaCode\\javaclass\\day27-code\\file\\demo6\\a\\a.txt", "UTF-8");
        System.out.println(list1);


    }
}
